package com.weir.workdemo.work01.event;

import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;

/**
 * @author weir
 */

@Slf4j
public class EventListener {
    private int eventHandler;

    @Subscribe
    public void StringEvent(String eventParam) {
        eventHandler++ ;
        log.info("subscribe: {}-{}", eventParam, eventHandler);
    }

    public static void main(String[] args) {
        EventBus eventBus = new EventBus();
        eventBus.register(new EventListener());
        for (int i = 0; i < 10; i++) {
            eventBus.post("envet-->" + i);
        }
    }
}
